package com.dbf.forum.controller.common;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.XmlWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;



@Order(0)
public class SpringWebAppInitializer 
implements WebApplicationInitializer 
{
	public static ApplicationContext context = null;
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
    	
		try
		{
		context = new ClassPathXmlApplicationContext("META-INF/application-context.xml");
		
//		XmlWebApplicationContext appContext = new XmlWebApplicationContext();
//	      appContext.setConfigLocation("/WEB-INF/dispatcher-servlet.xml");
//	
//	      ServletRegistration.Dynamic dispatcher =
//	    		  servletContext.addServlet("dispatcher", new DispatcherServlet(appContext));
//	      dispatcher.setLoadOnStartup(1);
//	      dispatcher.addMapping("/");
		}catch(Exception e){
			e.printStackTrace();
		}
         
    }

}
